<!DOCTYPE HTML>
<html>
	<head>
		<meta charset="utf-8" />
		<title>订单列表-{eyou:global name='web_name' /}</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
		<link href="{eyou:global name='web_cmspath'/}/favicon.ico" rel="shortcut icon" type="image/x-icon" />
		{eyou:static file="users/skin/css/bootstrap.min.css"/}
		{eyou:static file="users/skin/css/basic.css"/}
		{eyou:static file="users/skin/css/eyoucms.css"/}
		{eyou:static file="users/skin/css/shop.css"/}
		<!-- 新样式 2020-11-25 -->
		{eyou:static file="users/skin/css/element/index.css" /}
		{eyou:static file="users/skin/css/e-user.css" /}
		{eyou:include file="users/skin/css/diy_css.htm"/}

		{eyou:static file="/public/static/common/js/jquery.min.js"/}
		{eyou:static file="/public/plugins/layer-v3.1.0/layer.js"/}
		{eyou:static file="/public/static/common/js/tag_global.js"/}
	</head>

	<body class="centre shop">
		<!-- 头部 -->
		{eyou:include file="users/users_header.htm" /}
		<!-- 头部结束 -->
        <div class="breadcrumbs">
            <div class="w1226">
                <a href="{eyou:global name='web_cmsurl'/}">首页</a> <span class="sep">/</span> <a href="{eyou:url link='user/Users/index' /}">会员中心</a> <span class="sep">/</span> <span>我的订单</span>
            </div>
        </div>

		<div class="ey-body-bg">
			<div class="ey-body pd0">
				<div class="ey-container w1226">
					<!-- 侧边 -->
					{eyou:include file="users/users_left.htm" /}
					<!-- 侧边结束 -->
					<!-- 中部 -->
					<div class="ey-con fr">
						<div class="el-main main-bg xin_mian">
							<div class="el-row shop-oper">
                                <h1 class="title"> 我的订单<small>请谨防钓鱼链接或诈骗电话</small></h1>
							   	<div class="shop-oper-l">
								   	<!-- 订单导航栏 -->
								   	{eyou:spstatus id="field3"}
								   	<div class="el-button-group">
									   	<a class="el-button-xin first el-button--default {if empty($field3.select_status) && $field3.access_action == 'shop_centre'}active{/if}" data-toggle="tab" href="{eyou:url link='user/Shop/shop_centre'/}"> 全部有效订单{eyou:if condition="0 != $field3.All"} <em>({$field3.All})</em> {/eyou:if} </a>

									  	<a class="el-button-xin el-button--default {eq name='$field3.select_status' value='dzf'}active{/eq}" data-toggle="tab" href="{eyou:url link='user/Shop/shop_centre' vars='select_status=dzf'/}"> 待支付{eyou:if condition="0 != $field3.PendingPayment"} <em>({$field3.PendingPayment})</em> {/eyou:if} </a>

									  	<a class="el-button-xin el-button--default {eq name='$field3.select_status' value='2'}active{/eq}" data-toggle="tab" href="{eyou:url link='user/Shop/shop_centre' vars='select_status=2'/}"> 待收货{eyou:if condition="0 != $field3.PendingReceipt"} <em>({$field3.PendingReceipt})</em> {/eyou:if} </a>

									   	<a class="el-button-xin el-button--default {eq name='$field3.select_status' value='3'}active{/eq}" data-toggle="tab" href="{eyou:url link='user/Shop/shop_centre' vars='select_status=3'/}"> 已完成{eyou:if condition="0 != $field3.Completed"} <em>({$field3.Completed})</em> {/eyou:if}</a>
								   	</div>
								   	{/eyou:spstatus}
								   	<!-- 订单导航栏结束 -->
							   	</div>

							   	<div class="shop-oper-r">
								   	<!-- 查询栏 -->
								   	{eyou:spsearch id="search"}
								   	<form action="{$search.action}" method="get" >
									   {$search.hidden}
									   	<div class="input-with-select el-input el-input-group el-input-group--append">
                                            <input type="search" name="keywords" value="{$Request.param.keywords}" autocomplete="off" placeholder="输入商品名称、订单号" class="search-text">
                                            <input type="submit" value="" class="search-btn iconfont">
										   	
										</div>
									</form>
									{/eyou:spsearch}
								    <!-- 查询栏结束 -->	
							   	</div>
							</div>

							{eyou:empty name="$eyou.field.data"}
							<!-- 订单数据为空 -->
							<div class="ey-con-inside">
								<div class="el-row tc pt100 pb100 bgfff">
									<p class="mb10"><img id='litpic_img'  src="__PUBLIC__/static/common/images/null-data.png"/></p>
									<a href="{eyou:global name='web_cmsurl' /}" class="el-button el-button--default">马上去购物</a>
								</div>
							</div>
							{eyou:else/}
							<!-- 获取订单数据列表 -->
							<div class="goods-con">
								<div>
								    <ul class="order-list">
                                        {eyou:sporderlist id="field" pagesize="10"}
								        <li class="uc-order-item {eyou:eq name='$field.order_status' value='0'}uc-order-item-pay{/eyou:eq} {eyou:eq name='$field.order_status' value='1'}uc-order-item-shipping{/eyou:eq} {eyou:eq name='$field.order_status' value='2'}uc-order-item-shipping{/eyou:eq} {eyou:eq name='$field.order_status' value='3'}uc-order-item-finish{/eyou:eq} {eyou:eq name='$field.order_status' value='-1'}uc-order-item-finish{/eyou:eq}">
								            <div class="order-detail">
								                <div class="order-summary">
													{eyou:eq name="$field.order_status" value="-1"}
													<div class="order-status"> 已关闭 </div>
													{/eyou:eq}
                                                    {eyou:eq name="$field.order_status" value="0"}
                                                    <div class="order-status"> 等待付款 </div>
                                                    {/eyou:eq}
                                                    {eyou:eq name="$field.order_status" value="1"}
                                                    <div class="order-status"> 待发货 </div>
                                                    {/eyou:eq}
                                                    {eyou:eq name="$field.order_status" value="2"}
                                                    <div class="order-status"> 待收货 </div>
								                    {/eyou:eq}
                                                    {eyou:eq name="$field.order_status" value="3"}
                                                    <div class="order-status"> 已收货 </div>
                                                    {/eyou:eq}
								                </div>
								                <table class="order-detail-table">
								                    <thead>
								                        <tr>
								                            <th class="col-main">
								                                <p class="caption-info"> {$field.add_time|date='Y年m月d日 H:i:s',###} <span class="sep">|</span> {$field.consignee} <span class="sep">|</span> 订单号：<a href="{$field.OrderDetailsUrl}">{$field.order_code}</a><span class="sep">|</span>{$field.pay_name}</p>
								                            </th>
								                            <th class="col-sub">
								                                <p class="caption-price"> 应付金额： <span class="num">{$field.order_amount}</span>元 </p>
								                            </th>
								                        </tr>
								                    </thead>
								                    <tbody>
								                        <tr>
								                            <td class="order-items">
								                                <ul class="goods-list">
                                                                    {eyou:spordergoods id="order_field"}
								                                    <li>
								                                        <div class="figure figure-thumb">
								                                            <a href="{$order_field.arcurl}" target="_blank">
								                                                <img src="{$order_field.litpic}" width="80" height="80" alt="{$order_field.product_name}">
								                                            </a>
								                                        </div>
								                                        <p class="name">
								                                            <a href="{$order_field.arcurl}" target="_blank">
								                                            	{$order_field.product_name}&nbsp;
						                                                        <!-- 商品规格 -->
						                                                        {eyou:volist name='$order_field.product_spec_list' id='spec'}
						                                                            {$spec.value}&nbsp;
						                                                        {/eyou:volist}
						                                                        <!-- 商品规格 END-->
								                                            </a>
								                                        </p>
								                                        <p class="price">
								                                            {$order_field.product_price}元 × {$order_field.num}
								                                        </p>
								                                    </li>
                                                                    {/eyou:spordergoods}
								                                </ul>
								                            </td>
								                            <td class="order-actions">
								                                {eyou:eq name="$field.order_status" value="0"}
								                                	{eyou:eq name="is_wechat" value='2'}
								                                		<a href="{$field.PaymentUrl}" target="_blank" class="btn-small btn-primary">立即付款</a>
								                                	{eyou:else/}
								                                		<a href="JavaScript:void(0);" class="btn-small btn-primary" onClick="UpdatePayMethod('{$field.order_id}', '{$field.order_code}', 2);">立即付款</a> 
								                                	{/eyou:eq}
								                                {/eyou:eq}
                                                                <!-- 订单状态判断，待发货 -->
                                                                {eyou:eq name="$field.order_status" value="1"}
                                                                    <a href="javascript:void(0);" class="btn-small btn-line-gray" {$field.OrderRemind}>提醒发货</a>
                                                                {/eyou:eq}
                                                                <!-- 待发货结束 -->
                                                                
                                                                <!-- 订单状态判断，待收货 -->
                                                                {eyou:eq name="$field.order_status" value="2"}
                                                                	<!-- 订单类型判断，普通订单可查看物流，虚拟订单无需查看物流 -->
                                                                	{eyou:eq name="$field.prom_type" value="0"}
                                                                		{eyou:eq name="$is_wechat" value="1"}
                                                                            <a href="{$field.MobileExpressUrl}" class="btn-small btn-line-gray">物流查询</a>
                                                                		{eyou:else/}
                                                                            <a href="JavaScript:void(0);" class="btn-small btn-line-gray" {$field.LogisticsInquiry}>物流查询</a>
                                                                		{/eyou:eq}
                                                                	{/eyou:eq}
                                                                	<!-- 订单类型判断结束 -->
                                                                    <a href="javascript:void(0)" class="btn-small btn-line-gray" {$field.Confirm}>确认收货</a>
                                                                {/eyou:eq}
                                                                <!-- 待收货结束 -->
                                                                
                                                                <!-- 订单状态判断，已完成 -->
                                                                {eyou:eq name="$field.order_status" value="3"}
                                                                    <a href="JavaScript:void(0);" class="btn-small btn-line-gray">已完成</a>
                                                                {/eyou:eq}
                                                                <!-- 已完成结束 -->
                                                                
								                                <a href="{$field.OrderDetailsUrl}" class="btn-small btn-line-gray">订单详情</a>

																{eyou:eq name="$field.order_status" value="3"}
																	<a href="{$field.ServiceList}" class="btn-small btn-line-gray" target="_blank">申请售后</a>


																	{eyou:eq name="$field.is_comment" value="0"}
																	<a href="{$field.AddProduct}" class="btn-small btn-line-gray" target="_blank">评价商品</a>
																	{/eyou:eq}
																{/eyou:eq}
								                                
								                            </td>
								                        </tr>
								                    </tbody>
								                </table>
								            </div>
								        </li>
                                        {$field.hidden}
                                        {/eyou:sporderlist}
								    </ul>
                                    <!-- 分页输出 -->
                                    <div class="dataTables_paginate ">
                                    	<ul class="pagination">
                                    		{eyou:sppageorder listitem="index,end,pre,next" listsize="2"/}
                                    	</ul>
                                    </div>
                                    <!-- 分页输出结束 -->
								</div>
                            </div>
                            {/eyou:empty}
                         </div>
                    </div>
                    <!-- 中部结束 -->
                </div>
                
            </div>

            <input type="hidden" id="unified_id">
            <input type="hidden" id="unified_number">
            <input type="hidden" id="transaction_type">
        </div>

<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
<script type="text/javascript">
	$(function() {
		wx.miniProgram.getEnv(function(res) {
			if (res.miniprogram) {
				// 小程序
				var i = 0;
				i = setInterval('AppletsPay()', 1000);
			}
		});
	});

	// 小程序查询
	function AppletsPay() {
		var unified_id = $('#unified_id').val();
		var unified_number = $('#unified_number').val();
		var transaction_type = $('#transaction_type').val();
		if (unified_id && unified_number && transaction_type) {
			$.ajax({
				url: "{eyou:url link='user/Pay/ajax_applets_pay'/}",
				data: {
					unified_id: unified_id,
					unified_number: unified_number,
					transaction_type: transaction_type
				},
				type: 'post',
				dataType: 'json',
				success: function(res) {
					if (1 == res.code) {
						if (!res.data.mobile && !res.data.email) window.location.href = res.url;
						if (res.data.mobile) SendMobile(res.data.mobile);
						if (res.data.email) SendEmail(res.data.email);
						window.location.href = res.url;
					}
				}
			});
		}
	}

	// 判断支付类型是否一致并且更新支付方式
	function UpdatePayMethod(unified_id, unified_number, transaction_type) {
		layer_loading('正在处理');
		$.ajax({
			url: "{eyou:url link='user/Pay/update_pay_method'/}",
			data: {
				unified_id: unified_id,
				unified_number: unified_number,
				pay_method: 'WeChatInternal',
				transaction_type: transaction_type,
				order_source: 2
			},
			type: 'post',
			dataType: 'json',
			success: function(res) {
				layer.closeAll();
				if (0 == res.code) {
					showErrorAlert(res.msg);
				} else {
					if (1 == res.data.is_gourl) {
						window.location.href = res.url;
					} else {
						$('#unified_id').val(unified_id);
						$('#unified_number').val(unified_number);
						$('#transaction_type').val(transaction_type);
						WeChatInternal(unified_id, unified_number, transaction_type);
					}
				}
			}
		});
	}

	// 微信内部中进行支付
	function WeChatInternal(unified_id, unified_number, transaction_type) {
		wx.miniProgram.getEnv(function(res) {
			if (res.miniprogram) {
				// 小程序
				wx.miniProgram.navigateTo({
					url: '/pages/pay/pay?unified_id=' + unified_id + '&unified_number=' + unified_number + '&type=' +
						transaction_type
				});
			} else {
				// 微信端
				$.ajax({
					url: "{eyou:url link='user/Pay/wechat_pay'/}",
					data: {
						unified_id: unified_id,
						unified_number: unified_number,
						transaction_type: transaction_type
					},
					type: 'post',
					dataType: 'json',
					success: function(res) {
						layer.closeAll();
						if (1 == res.code) {
							callpay(res.msg);
						} else {
							showErrorAlert(res.msg);
						}
					}
				});
			}
		});
	}

	//调用微信JS api 支付
	function jsApiCall(data) {
		WeixinJSBridge.invoke(
			'getBrandWCPayRequest', data,
			function(res) {
				if (res.err_msg == "get_brand_wcpay_request:ok") {
					layer.msg('微信支付完成！', {
						time: 1000
					}, function() {
						pay_deal_with();
					});
				} else if (res.err_msg == "get_brand_wcpay_request:cancel") {
					showErrorAlert('用户取消支付！');
				} else {
					showErrorAlert('支付失败，原因可能是订单号已支付！');
				}
			}
		);
	}

	// 微信内部支付时，先进行数据判断
	function callpay(data) {
		if (typeof WeixinJSBridge == "undefined") {
			if (document.addEventListener) {
				document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
			} else if (document.attachEvent) {
				document.attachEvent('WeixinJSBridgeReady', jsApiCall);
				document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
			}
		} else {
			jsApiCall(data);
		}
	}

	function pay_deal_with() {
		var unified_number = $('#unified_number').val();
		var transaction_type = $('#transaction_type').val();
		$.ajax({
			url: "{eyou:url link='user/Pay/pay_deal_with'/}",
			data: {
				unified_number: unified_number,
				transaction_type: transaction_type
			},
			type: 'post',
			dataType: 'json',
			success: function(res) {
				if (1 == res.data.status) {
					if (!res.data.mobile && !res.data.email) window.location.href = res.url;
					if (res.data.mobile) SendMobile(res.data.mobile);
					if (res.data.email) SendEmail(res.data.email);
					window.location.href = res.url;
				}
			}
		});
	}

	// 发送短信
	function SendMobile(result) {
		if (result) {
			$.ajax({
				url: result.url,
				data: result.data,
				type: 'post',
				dataType: 'json'
			});
		}
	}

	// 发送邮件
	function SendEmail(result) {
		if (result) {
			$.ajax({
				url: result.url,
				data: result.data,
				type: 'post',
				dataType: 'json'
			});
		}
	}
</script>
{eyou:include file="users/users_footer.htm" /}
